
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>逐帧动画</title>
  <style>
    .container {
      width: 100px;
      height: 100px;
      border: 1px solid red;
      background: url(./animal.png) no-repeat;
      animation: run 1s infinite;
      animation-timing-function: steps(1); /*每一帧之间需要出现几个画面*/
    }
    @keyframes run{
      0% {
        background-position: 0 0;
      }
      12.5% {
        background-position: -100px 0;
      }
      25% {
        background-position: -200px 0;
      }
      37.5% {
        background-position: -300px 0;
      }
      50% {
        background-position: 0 -100px;
      }
      62.5% {
        background-position: -100px -100px;
      }
      75% {
        background-position: -200px -100px;
      }
      87.5% {
        background-position: -300px -100px;
      }
      100% {
        background-position: 0 0;
      }
    }
  </style>
</head>
<body>
  <div class="container">
  </div>
</body>
</html>
